class UserMailer < ActionMailer::Base
  
  ADMINEMAIL = "zhong871004@163.com"
  
  def signup_notification(user)
    setup_email(user)
    @subject    += '分度：激活帐号'
  
    @body[:url]  = "#{SITE}/activate/#{user.activation_code}"
  
  end
  
  def activation(user)
    setup_email(user)
    @subject    += '您的帐号已成功激活'
    @body[:url]  = "#{SITE}/"
  end
  
  def modify_password(user)
    setup_email(user)
    @subject    += '找回您的密码'
    @body[:url] = "#{SITE}/reset_password/#{user.pwd_check_code}"
  end
  
  def friend_request(mail)
    setup_email(mail[:friend])
    @subject += "#{mail[:user].username}申请成为您的好友"
    @body = mail
  end
  
  protected
    def setup_email(user)
      @recipients  = "#{user.email}"
      @from        = ADMINEMAIL
      @subject     = "分度信息"
      @sent_on     = Time.now
      @body[:user] = user
      @charset     = "utf8"
      @content_type = "text/html"
    end

end
